package entity;


import java.io.Serializable;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import util.enumeration.ActivityType;
import util.enumeration.SingaporeArea;

/**
 *
 * @author KohLi
 */
@Entity(name="Activity")
@Inheritance(strategy = InheritanceType.JOINED)
public abstract class ActivityEntity implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    private String locale;
    private ActivityType activityType;
    private String activityName;
    private String activityDesc;
    private SingaporeArea singaporeArea;
    private String creator;
    
    @OneToOne(cascade={CascadeType.ALL}, orphanRemoval=true)
    private ActivityOrganiserEntity organiser;
    
    @OneToOne(cascade={CascadeType.ALL}, orphanRemoval=true)
    private ActivityAddressEntity venue;
    
    @OneToMany(cascade={CascadeType.PERSIST})
    private Collection<ActivityLocalizedEntity> localizedActivity;
    
    
    public ActivityEntity(){
        
    }
    
    
    public ActivityEntity(ActivityEntity temp){
        //this.organiser = temp.getOrganiser();
        this.activityType = temp.getActivityType();
        this.creator = temp.getCreator();
        this.singaporeArea = temp.getSingaporeArea();
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }
    
    public ActivityType getActivityType() {
        return activityType;
    }

    public void setActivityType(ActivityType activityType) {
        this.activityType = activityType;
    }

    public ActivityAddressEntity getVenue() {
        return venue;
    }

    public void setVenue(ActivityAddressEntity venue) {
        this.venue = venue;
    }

    public ActivityOrganiserEntity getOrganiser() {
        return organiser;
    }

    public void setOrganiser(ActivityOrganiserEntity organiser) {
        this.organiser = organiser;
    }

    public String getCreator() {
        return creator;
    }

    public void setCreator(String creator) {
        this.creator = creator;
    }

    public SingaporeArea getSingaporeArea() {
        return singaporeArea;
    }

    public void setSingaporeArea(SingaporeArea singaporeArea) {
        this.singaporeArea = singaporeArea;
    }

    public String getActivityDesc() {
        return activityDesc;
    }

    public void setActivityDesc(String activityDesc) {
        this.activityDesc = activityDesc;
    }

    public String getActivityName() {
        return activityName;
    }

    public void setActivityName(String activityName) {
        this.activityName = activityName;
    }

    public String getLocale() {
        return locale;
    }

    public void setLocale(String locale) {
        this.locale = locale;
    }

    public Collection<ActivityLocalizedEntity> getLocalizedActivity() {
        return localizedActivity;
    }

    public void setLocalizedActivity(Collection<ActivityLocalizedEntity> localizedActivity) {
        this.localizedActivity = localizedActivity;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ActivityEntity)) {
            return false;
        }
        ActivityEntity other = (ActivityEntity) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Activity[ id=" + id + " ]";
    }
  
}
